//
// Created by 束庆乐 on 2025/1/2.
//
#include "iostream"
using namespace std;

class Anmial{
public:
    //定义虚函数，编译期间不能确定函数调用
    virtual void speak(){
        cout << "动物在说话" << endl;
    }
};

class Cat:public Anmial{
public:
    void speak(){
        cout << "小猫在说话" << endl;
    }
};

class Dog:public Anmial{
public:
    void speak(){
        cout << "小狗在说话" << endl;
    }
};

void doSpeak(Anmial& ani){
    ani.speak();
}

int main085(){
    Cat cat;
    doSpeak(cat);

    Dog dog;
    doSpeak(dog);


    return 0;
}